package com.pet.comment.controller;

import com.pet.comment.service.ApCommentService;
import com.pet.model.comment.dtos.CommentDto;
import com.pet.model.comment.dtos.CommentLikeDto;
import com.pet.model.comment.dtos.CommentSaveDto;
import com.pet.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/*
 * 文章评论
 */
@RestController
@RequestMapping("api/comment")
public class ApCommentController {
    @Autowired
    private ApCommentService apCommentService;

    /**
     * 发布评论
     */
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto){
        return apCommentService.saveComment(dto);
    }

    /**
     * 评论点赞
     */
    @PostMapping("/like")
    public ResponseResult<Map<String, Object>> likeComment(@RequestBody CommentLikeDto dto){
        return apCommentService.likeComment(dto);
    }

    /**
     * 加载评论列表
     */
    @PostMapping("/load")
    public ResponseResult<List> loadComment(@RequestBody CommentDto dto){
        return apCommentService.loadComment(dto);
    }
}
